package org.liuyunfeng.domain;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.apache.commons.lang.RandomStringUtils;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.Random;

/**
 * @author: TanJingyu
 * @create: 2022-03-18 13:52
 **/
@Getter
@Setter
@Accessors(chain = true)
@ToString
public class Order {
    private Long id;
    private String amount;
    private String skuName;
    private Date createTime;

    public static Order randomOrder() {
        return new Order()
                .setCreateTime(new Date())
                .setId(randomId())
                .setAmount(randomAmount())
                .setSkuName(randomSkuName());
    }

    private static Long randomId() {
        return new Random().longs(1, 1, 10000000).sum();
    }

    private static String randomAmount() {
        return Double.toString(new Random().doubles(1, 99, 9999).sum());
    }

    private static String randomSkuName() {
        return RandomStringUtils.random(8);
    }


    public static void main(String[] args) {
        System.out.println(Order.randomOrder());
    }
}